<%@ page import="com.fhd.constant.Constants" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.fhd.pojo.Recharge" %><%--
  Created by IntelliJ IDEA.
  User: 44252
  Date: 2025/3/29
  Time: 10:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>客户充值管理</title>
</head>
<body>
<h2>
以下是所有客户的充值记录：
</h2>
<a href="<%=request.getContextPath()%>/jsp/managerFrame.jsp">返回管理员主页</a><br>
<%
    // 判断有无操作提示
    String message = (String) request.getSession().getAttribute(Constants.UPDATE_RECHARGE_SITUATION_MESSAGE);
    if (message != null) {
        out.write("<h3 style=\"color: red\">" + message + "</h3>");
        request.getSession().removeAttribute(Constants.UPDATE_RECHARGE_SITUATION_MESSAGE);
    }

    String object = (String) request.getSession().getAttribute(Constants.GET_ALL_RECHARGE_MESSAGE);
    // 判断控制层传的是信息还是对象
    if (object != null) {
        out.print("<h3 style=\"color: red\">" + object + "</h3>");
        request.getSession().removeAttribute(Constants.GET_ALL_RECHARGE_MESSAGE);
    } else {
        ArrayList<Recharge> recharges = (ArrayList<Recharge>) request.getSession().getAttribute(Constants.GET_ALL_RECHARGE_SESSION);
        if (recharges != null && !recharges.isEmpty()) {
            // 每一个充值数据，等待被确认需要显示操作按钮让管理员操作，已确认或已取消就不用
            for (int i = 0; i < recharges.size(); i++) {
                Recharge recharge = recharges.get(i);
                out.print("充值编号：" + recharge.getId() + "<br>");
                out.print("充值客户id：" + recharge.getClientId() + "<br>");
                out.print("充值客户用户名：" + recharge.getClientName() + "<br>");
                out.print("充值金额：" + recharge.getMoney() + "<br>");
                int situation = recharge.getSituation();
                if (situation == 1) {
                    out.print("充值状态：等待确认<br>");
%>
<form action="<%=request.getContextPath()%>/manager.do" method="post">
  <input type="hidden" name="method" value="changeRechargeSituation">
  <input type="hidden" name="id" value="<%=recharge.getId()%>">
  <input type="hidden" name="clientId" value="<%=recharge.getClientId()%>">
  <input type="hidden" name="money" value="<%=recharge.getMoney()%>">
  <input type="submit" name="rechargeSituation" value="通过">
  <input type="submit" name="rechargeSituation" value="取消">
</form>
<%
            } else if (situation == 2){
              out.print("充值状态：已通过<br>");
            } else {
              out.print("充值状态：被取消<br>");
            }
            out.print("=========================<br>");
        }
      }
  }
%>
</body>
</html>
